/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simhya.model.store.jepstore;
import simhya.model.store.Function;
import java.util.ArrayList;
import simhya.model.store.Store;
import org.nfunk.jep.Variable;
import simhya.matheval.SymbolArray;

/**
 *
 * @author Luca
 */
public class LinearFunction implements Function{
    private int var;
    private int par;
    private Store store;
    private Variable[] variables;
    private Variable[] parameters;

    public LinearFunction(Store store, int par, int var) {
        this.store = store;
        this.var = var;
        this.par = par;
        this.store.addExternalFunction(this);
    }


     public void initialize() {
        this.variables = (Variable[])store.getVariables();
        this.parameters = (Variable[])store.getParameters();
    }

    public double compute() {
        return (Double)parameters[par].getValue() * (Double)variables[var].getValue();
    }

    public double compute(SymbolArray vars) {
        throw new UnsupportedOperationException("Not supported yet.");
    }


    public ArrayList<Integer> getVariableList() {
        ArrayList<Integer> list = new ArrayList();
        list.add(var);
        return list;
    }


}
